<?php declare(strict_types=1);


namespace PinWuYun\domain\dao;


use PinWuYun\domain\models\GoodsRelationModel;

/**
 * Created: by zhiJie
 * Date: 2021/7/1
 */
class GoodsReleaseDao
{
    /**
     *  保存一条数据
     * @param $params [
     *              'star_spu_id'=>'',
                   'you_alias'=>'',
                   'you_item_id'=>'',
     *          ]
     * @return bool
     */
    public static function insert($params): bool
    {
        $model = new GoodsRelationModel();
        $model->setRawAttributes([
            'star_spu_id' => $params['star_spu_id'],
            'you_alias' => $params['you_alias'],
            'you_item_id' => $params['you_item_id'],
        ]);
        return $model->save();

    }

    /**
     * @param $spuId
     * @return mixed
     */
    public function getItemId($spuId)
    {
        return GoodsRelationModel::query()->where([
            'star_spu_id' => $spuId
        ])->value('you_item_id');
    }
}